home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Orlando_1993 / Devcon93.4 / Notes / Compatibility < prev    next >
Encoding:
Text File  |  1993-01-05  |  49.2 KB  |  1,122 lines

  1.  
  2.  
  3.  
  4.                             V39 and AA Compatibility
  5.  
  6.             Commodore Engineering and CATS
  7.  
  8. Introduction
  9.  
  10. The capabilities of the built-in Amiga graphics hardware did not change
  11. significantly between the introduction of the Amiga 1000 in 1985 and the
  12. release of the Amiga 3000 in 1990.  The ECS chip set and the display enhancer
  13. added several new graphics modes and increased the functionality of existing
  14. modes -- yet the market demanded more.
  15.  
  16. This document explains some of the features of the latest generation Amiga
  17. graphics hardware known as the the AA (double-A) chip set, and ways to ensure
  18. application compatibility with these and other V39 features and changes.
  19. Additionally, coding methods are outlined which will allow current software
  20. to automatically exploit some of the new features.
  21.  
  22.  
  23. New Hardware Features
  24.  
  25. The most important capabilities of the new Amiga graphics
  26. hardware are summarized below.
  27.  
  28. o  Enhanced Bandwidth.  A 32-bit wide data bus allows doubling of
  29. Chip memory bandwidth (up to 2x the normal bandwidth) and supports the
  30. input of 32-bit wide bitplane and sprite data.  Bandwidth may be
  31. doubled again (to 4x) by using Fast Page Mode RAM.
  32.  
  33. o  More Bitplanes.  The maximum number of bitplanes has increased
  34. to 8 in all resolution modes.  This translates to a 256-entry
  35. color table for each available mode.
  36.  
  37. o  Larger Palette.  Each entry in the color table may now be 25
  38. bits wide (8 bits each for Red, Blue, and Green data plus 1 bit
  39. for genlock information).  This translates to a palette of
  40. 16,777,216 colors.
  41.  
  42. o  HAM and HALFBRITE are available in all display resolutions and depths,
  43. allowing for greatly enhanced dipslay modes such as 8-bitplane HIRES HAM.
  44.  
  45. o  Enhanced Dual Playfield Support.  Each playfield may now have
  46. up to 4 bitplanes.  The bank of 16 colors in the 256-color table
  47. is independently selectable for each playfield.
  48.  
  49. o  Enhanced Sprite Support.  Sprite resolution can be set to
  50. Lores, Hires, or SuperHires, independent of screen resolution. 
  51. Attached sprites are now available in all modes.  However, some new higher
  52. bandwidth modes may only allow one sprite (making an attached sprite impossible).
  53. Odd and even sprites may use their own independent 16-color bank from the
  54. 256-color table.  Old format sprites are still 16 bits wide, but new format
  55. sprites may be 32 or 64 bits wide.  Sprites may now optionally appear in the
  56. border region.  The horizontal positioning resolution of sprites has increased
  57. to 35ns (equivalent to SuperHires pixel widths.)
  58.  
  59. o  Enhanced hardware scrolling support.  The resolution of bitplane
  60. scrolling has increased to 35ns.
  61.  
  62. o  Hardware scan-doubling support.  15 kHz bitplanes and sprites
  63. may now be scan-doubled for flicker-free display on 31 kHz
  64. monitors, and for enhanced display sharing with 31 kHz bitplanes.
  65.  
  66. o  ECS compatibility.  New chips will power-up in an ECS
  67. compatibility mode, which will allow many older self-booting
  68. programs to be run on new machines.
  69.  
  70.  
  71.  
  72. Ensuring Compatibility
  73.  
  74. This section covers programming techniques that will help ensure
  75. that your application will work as expected when running under V39
  76. and on systems that use AA and future generation graphics hardware.
  77.  
  78. Support of Release 2 is integral to supporting new graphics chips.
  79. One of the main reasons is the display database.  Starting with
  80. the ECS chip set, not all machines have all display modes available.
  81. This will be even more true in the future.  The only way to know if
  82. a particular mode is available is to check the display database.
  83.  
  84. For a detailed explanation of how to properly open a screen using
  85. the display database information to check for available modes,
  86. refer to the Amiga ROM Kernel Reference Manual: Libraries, 3rd Edition.
  87. Also  see the Amiga Mail articles entitled "An Introduction to V36 Screens
  88. and Windows" (page IV-3) and "Opening Screens and Windows on Any Amiga"
  89. (Page IV-17).  Some other pertinent details can also be found in the Paris
  90. DevCon notes article entitled "Monitors, Modes, and the Display Database."
  91.  
  92. Once a screen or other display has been opened, all manipulations should
  93. also be handled using system calls.  In particular, these manipulations
  94. must be handled by the system software:
  95.  
  96. o  Allocation of graphics resources - use the graphics or intuition library
  97.  
  98. o  Palette manipulation - use the graphics library
  99.  
  100. o  Manipulating mouse pointer sprite - use intuition.library to
  101.    select or change imagery; input.device to move it
  102.  
  103. o  Manipulating sprites other than the mouse pointer - use the graphics library
  104.  
  105. o  Manipulating icons - use the icon library
  106.  
  107. o  Allocating and changing colormaps and colortables - use the
  108. graphics library
  109.  
  110. o  Bitplane allocations - use AllocBitMap() under V39 and higher,
  111. and AllocRaster() under earlier releases, but please refer to
  112. the next section for important information about limitations of
  113. AllocRaster().
  114.  
  115. Furthermore, these manipulations should be handled by the system
  116. software whenever possible:
  117.  
  118. o  Drawing operations - use the graphics library and Intuition
  119. library
  120.  
  121. o  Blitter operations - if possible, use only use higher level blitter
  122. functions from graphics.library such as BltBitMap(), BltRastPort(), etc.
  123. If you must wait for a blit to complete, always use the system's WaitBlit()
  124. function, never your own.  The system knows about and handles problems with
  125. the BLITTER_DONE signal that different revisions of the Agnus chip have.
  126. If you feel that must use the blitter hardware directly (sacrificing all
  127. hope for any RTG compatibility), be sure to properly OwnBlitter, then
  128. WaitBlit, then use blitter, then DisownBlitter.
  129.  
  130. Remember that system structures are subject to change or extension.
  131. For new graphics hardware, structures likely to be extended are those
  132. associated with ColorMaps, ViewPortExtras, Sprites, and many others.
  133. To deal with changing system structures, developers should use system
  134. calls to allocate, create, and manipulate these structures.  
  135. Many new "Get" and "Set" calls have been added to graphics.library
  136. to provide an upwards-compatible mechanism for reading and setting
  137. structure members which were previously accessed by program code either
  138. directly or through macros which accessed them directly.
  139. For future compatibility, do not directly access or change any
  140. structure or value for which a "Get" and "Set" call is available.
  141. And do not declare or AllocMem any structure for which a special
  142. allocation call is provided.
  143.  
  144. Most of the new new "Get" and "Set" graphics calls for V39 are listed below.
  145. Note that some of these functions are workalike replacements for old
  146. gfxmacros which poked or peeked a structure, and others provide tag-based
  147. capability for getting and/or setting more than one attribute (Attr) of
  148. a structure:
  149.  
  150. GetAPen(rp)(a0)
  151. GetBPen(rp)(a0)
  152. GetDrMd(rp)(a0)
  153. SetABPenDrMd(rp,apen,bpen,drawmode)(a1,d0/d1/d2)
  154. GetOutlinePen(rp)(a0)
  155. SetOutlinePen(rp,pen)(a0,d0)
  156. GetBitMapAttr(bm,attrnum)(a0,d1)
  157. SetWriteMask(rp,msk)(a0,d0)
  158. SetMaxPen(rp,maxpen)(a0,d0)
  159. SetRPAttrsA(rp,tags)(a0/a1)
  160. GetRPAttrsA(rp,tags)(a0/a1)
  161.  
  162.  
  163. Use the newest functions available.  For compatibility reasons, it
  164. is sometimes not possible to change the behavior of an existing system
  165. function to provide enhanced capabilities.  In such cases, new functions
  166. may be provided.  For upwards compatibility, conditionally use the newest
  167. functions that are available.  For example, when running under an OS
  168. earlier than V39, applications that wish to allocate a BitMap should use
  169. AllocRaster() and InitBitMap().  New or updated applications should use
  170. the new AllocBitMap() call instead when running under V39 or higher.
  171. See the V39 graphics library Autodocs for specifications of new functions
  172. such as AllocBitMap().
  173.  
  174.  
  175. Hardware Compatibility
  176.  
  177. The new chips power-up in an ECS compatible state that allows a
  178. large portion of older, self-booting (i.e., game) software to run
  179. even though these older titles often access hardware registers
  180. directly.  However, directly accessing hardware should be avoided
  181. by any software that expects to run after the operating system has
  182. been started.  Keep in mind also that it is difficult to maintain
  183. hardware register-level compatibility even on powerup as new and
  184. more enhanced chip sets are developed.  Avoid directly programming the
  185. hardware whenever possible.
  186.  
  187. In cases where applications _must_ access the hardware:
  188.  
  189. o  Applications must not write spurious data to,
  190.    or interpret data from, currently unused bits or addresses.
  191.  
  192. o  Applications must set undefined bits to zero for writes and
  193.    ignore them for reads.
  194.  
  195. o  Mask out all the bits except the ones the application is
  196.    actually interested in.
  197.  
  198. o  Do not assume the initial state of any registers.
  199.  
  200. o  Do not read write-only registers or write to read-only registers.
  201.  
  202. o  Do not read or write BYTEs to the custom chip registers
  203. (they are WORD registers).
  204.  
  205.  
  206. Graphics and Intuition Issues
  207.  
  208. The following notes detail some known coding practices that can
  209. cause software to function incorrectly on V39 and AA machines.
  210.  
  211.  
  212. o  BitMap plane allocations unsuitable for new modes.
  213. This problem surfaces because the new chips have an increased fetch bandwidth. 
  214. The data for each bitplane scan line must be properly aligned in Chip memory
  215. for new display modes to work.
  216.  
  217. For instance, these allocation methods should all be avoided under V39
  218. and higher:
  219.  
  220. /* WRONG for AA */
  221. for(planenum=0; planenum<DEPTH; planenum++)                 
  222.    bitmap.Planes[planenum]=(PLANEPTR)AllocMem(RASSIZE(width,height),MEMF_CHIP);
  223.  
  224. /* Also WRONG */
  225. allplanes=AllocMem(DEPTH*RASSIZE(width,height),MEMF_CHIP);  
  226.  
  227. /* Also WRONG */
  228. for(planenum=0; planenum<DEPTH; planenum++)
  229.     bitmap.Planes[planenum]=(PLANEPTR)AllocRaster(width,height);
  230.  
  231. The correct V39 method for allocating rasters is to use AllocBitMap()
  232. for graphics-level bitmaps or for CUSTOMBITMAP screens, or let Intuition
  233. OpenScreen() or OpenScreenTagList() allocate your bitmap.  This method will
  234. allow you to get the greater bandwidth and more efficient displays available
  235. under V39 in a manner that will be upward-compatible with future enhancements.
  236. The new V39 graphics function AllocBitMap() properly handles all allocation
  237. and alignment issues.  The Intuition OpenScreenTags() call uses AllocBitMap()
  238. under V39.
  239.  
  240. If for some reason your existing code design prevents you from conditionally
  241. calling AllocBitMap() or OpenScreen() when running under V39 and higher,
  242. you may be able to at least get compatibility with the currently available
  243. higher-bandwidth modes by using AllocRaster() or AllocMem() after rounding
  244. your width up to a multiple of 64 pixels (absolutely no guarantees here;
  245. future chips may require greater alignment; we suggest you conditionally
  246. code to use AllocBitMap() for future compatibility).
  247.     
  248. o  Incorrect assumptions about BitMap->BytesPerRow.
  249. Applications that use system functions to initialize and allocate BitMaps
  250. and their elements should be aware that the value of BitMap->BytesPerRow
  251. may be different from the expected value, depending on the bandwidth mode
  252. chosen, the custom chip type, method of allocation, and the asked-for
  253. width of the allocated planes.
  254.  
  255. Here's the explanation.  First, due to fetch-alignment restrictions
  256. in AA, some modes require a higher granularity (BytesPerRow must
  257. be a multiple of 4 or 8, instead of just 2 under ECS).  Second,
  258. BytesPerRow actually means two different things, which have always
  259. been identical, but aren't any more when using interleaved bitmaps.
  260. BytesPerRow officially means "the number of bytes you have to add
  261. to a pointer to a byte of the BitMap to get to the same place one
  262. row down".  It no longer can be depended on to mean "the number
  263. of bytes in this row".
  264.  
  265. To detect software compatibility problems related to BytesPerRow
  266. changes,it is extremely important to test on a machine with the AA chipset
  267. and Mode Promotion turned on in the IControl Preferences editor,
  268. and if the software supports various display sizes, to test with sizes
  269. which are not divisible by 64.
  270. Two typical symptoms of BytesPerRow problems are 1. skewing of
  271. the display, where the pixel data for every line is progressively
  272. further right or left, giving a diagonal appearance to the display,
  273. and 2. images saved with excess blank space at the right.
  274.  
  275. NOTE - CATS intends to provide a developer tool, probably called "BumpBPR",
  276. which will force all Screen and AllocBitMap() BitMap widths to a multiple
  277. of 64 pixels to emulate the higher scanline alignment of higher bandwidth
  278. AA modes.  This should allow developers to test for many BitMap->BytesPerRow
  279. problems on non-AA and no-promotion machines running V39.
  280.  
  281. o Non-matching BitMap->BytesPerRow
  282. Some applications assume that two BitMaps of the same width, but allocated
  283. by different methods, will be swappable or block-copyable in various manners.
  284. This is often no longer the case.  For example, a BitMap allocated by
  285. OpenScreen (which calls AllocBitMap) may have raster line storage widths
  286. rounded up to provide higher alignment for higher-bandwidth displays.
  287. But the raster lines of BitMap planes allocated with AllocMem() are generally
  288. rounded up only to a multiple of 16 with a hardcoded macro (RASSIZE),
  289. and for compatibility reasons, AllocRaster() currently still performs
  290. only the same rounding to a multiple of 16.
  291.  
  292.  
  293. o Interleaved BitMaps
  294. For interleaved bitmaps, BytesPerRow is quite a bit larger than the
  295. number of bytes in this row.  Screen grabbers and screen printers seem
  296. to be the primary victims of this change.
  297. For compatibility, the Workbench screen is non-interleaved if it opens
  298. before IPrefs has run.  If opened or reset after IPrefs has run, the
  299. Workbench screen will be interleaved, so under V39, the Workbench
  300. screen in a normally booted environment is likely to be interleaved.
  301. GetBitMapAttr( bm, BMA_WIDTH ) can return the true width of a BitMap
  302. in pixels.  However, this is not the width to be used when saving a BitMap
  303. as an ILBM since this width may be rounded up for alignment reasons.
  304.  
  305.  
  306. o  Incorrect assumptions about the internal structure of BitMap plane data.
  307. New types of BitMaps may have a significantly different layout.
  308. For example, new V39 interleaved BitMaps are allocated as one contiguous
  309. block of Chip memory and and are internally different from non-interleaved
  310. plane data.
  311.  
  312. Interleaved BitMaps consist of line 0 of plane 0, followed by
  313. line 0 of plane 1, line 0 of plane 2, on through to line 0 of
  314. plane n.  Then the pattern repeats with the data for the next
  315. line.  This BitMap layout reduces the color flashing effect which
  316. normally accompanies the blitting of individual planes.  Interleaved
  317. BitMaps can be requested by applications under AA.  Note however,
  318. that callers are not guaranteed to receive an interleaved BitMap
  319. whenever they ask for one.  The BMF_INTERLEAVED flag to AllocBitMap()
  320. is considered  a request, not a requirement.  If no sufficiently large
  321. continuous block of chip memory is available, it may not be possible to
  322. allocate the BitMap interleaved.  In that case, AllocBitMap() will attempt
  323. to allocate an ordinary BitMap instead.  Applications should be written
  324. so as not to be sensitive to whether or not a BitMap is interleaved.
  325. In those rare cases when it might matter, GetBitMapAttr( BMA_FLAGS )
  326. can be used.
  327.  
  328. o  Incorrect assumptions about the Display Database.
  329. Data about a display mode could change between one version of Kickstart
  330. and another, between different models of the Amiga and even between
  331. similar models.  Treat the data in the display database as dynamic!
  332. Information that was available under V37 may not necessarily
  333. be available under V39.  For instance, VGA and A2024 mode
  334. information is no longer in ROM and unless they are added by the
  335. user, there will be no information about these modes available.
  336.  
  337. Never cache information about the DEFAULT_MONITOR_ID modes
  338. because the default monitor can be changed by the user with the
  339. promotion feature.  
  340.  
  341. Use the 2.1 asl.library screen mode requester to present your
  342. user with choices which are actually available (Note - 2.1 asl.library
  343. works under 2.0 Kickstart, and a free amendment to distribute 2.1
  344. asl.library is available for 2.0 Workbench licensees).
  345.  
  346. o  Direct handling of ViewPorts.
  347. Applications that use low-level graphics calls to create the View
  348. directly may have problems in V39.  MakeVPort() and MrgCop() can now
  349. return an error.  In addition, the gap required between ViewPorts may
  350. now need to be significantly larger than on pre-AA chips, where it was
  351. never more than 3 non-interlaced lines (6 interlaced lines).
  352. The V39 graphics function CalcIVG() (Calc Inter Viewport Gap) may be used
  353. to determine how many blank lines will be needed above a ViewPort.  Note
  354. that Intuition currently uses at least 3 lines, or MAX(3,CalcIVG(v,vp))
  355. (substitute 6 for 3 if interlaced).  Also note that for old display modes
  356. with old depths and 4-bit-per-gun colors, the gap is unchanged from
  357. that under the ECS and original chip sets.
  358.  
  359. o  Incorrect use of PAL or NTSC flags.
  360. The common method of determining whether a machine is running in
  361. PAL or NTSC mode has always been to check for the PAL bit in
  362. GfxBase->DisplayFlags:
  363.  
  364.     BOOL IsPAL;
  365.  
  366.     IsPAL=(GfxBase->DisplayFlags & PAL) ? TRUE : FALSE;
  367.  
  368. One classic reason for desiring such a PAL/NTSC determination is to decide
  369. what size or type display to open.  The other common reason is to determine
  370. what clock constant to use in serial or audio period calculations (Amigas
  371. built as PAL machines have a slightly different system clock crystal frequency
  372. than Amigas built as NTSC machines, and serial/audio period calculations are
  373. dependent on this frequency).
  374.  
  375. Because V37 and V39 are more adaptable, this bit may longer be counted
  376. on to mean the user's preferred display mode, nor to even signify the
  377. probable clock crystal in the user's system.
  378.  
  379. For accurate serial and audio period calculations, you need to determine
  380. whether the system has a system clock crystal designed for PAL or NTSC.
  381. There is no totally foolproof way of doing this.  Under 1.x through 2.x,
  382. your best indicator of whether a system has a PAL system clock crystal
  383. is the GfxBase->DisplayFlags PAL bit.  This bit should tell you the
  384. hardware default of the machine, and should only mislead you if the user
  385. has moved the PAL/NTSC jumper or has run a PD program to change the bootup
  386. mode between PAL and NTSC.
  387.  
  388. Under V39 (and probably above), new BootMenu options now allow the user
  389. to software-select PAL or NTSC as the default graphics environment.
  390. This can modify the GfxBase->DisplayFlags PAL bit, but obviously does not
  391. change the system clock crystal.  Therefore, under V39 and higher, a new
  392. DisplayFlags bit called REALLY_PAL has been added to signify the whether
  393. the motherboard hardware jumper setting appears to be PAL.  Therefore,
  394. under V39 and higher, the best bit available for determining NTSC or PAL
  395. hardware is the new REALLY_PAL bit.
  396.  
  397. If your software needs to determine the characteristics of default
  398. displays, prior to V37 look at DisplayFlags PAL bit.  Under V37 or higher,
  399. instead use GetDisplayInfoData() to get information about the modeid
  400. LORES_KEY or HIRES_KEY, and then check the DisplayInfo.PropertyFlags
  401. for properties such as DIPF_IS_PAL (which will be true for both
  402. PAL and DblPAL).
  403.  
  404. If your software instead needs to determine the characteristics of the
  405. user's preferred display mode to work in (as evidenced by the mode of
  406. their Workbench or other default public screen), you can GetDisplayInfoData()
  407. on the modeID of the default public screen.  Be aware however that this
  408. modeID might not be any of the PAL or NTSC modes, but rather VGA or some
  409. other mode.
  410.  
  411. #include <graphics/displayinfo.h>
  412.  
  413.     Bool IsPAL;
  414.     struct Screen *screen;
  415.     ULONG modeID = LORES_KEY;
  416.     struct DisplayInfo displayinfo;
  417.  
  418.     /* Open graphics.library, etc. */
  419.  
  420.     /* Above, modeID is initialized to LORES_KEY.  You should inquire
  421.      * about LORES_KEY or HIRES_KEY if you are interested in the
  422.      * display characteristics of default displays (for example, what
  423.      * OpenScreen() will provide if you don't use tags to ask for a
  424.      * display mode with an explicit monitor like PAL or NTSC or VGA).
  425.      *
  426.      * Do the following LockPubScreen part if you are instead interested
  427.      * in the display characteristics of the modeID of the user's default
  428.      * public screen (usually Workbench).
  429.      */
  430.     if (screen = LockPubScreen(NULL))
  431.     {
  432.         modeID = GetVPModeID(&(screen->ViewPort));
  433.         UnlockPubScreen(NULL,screen);
  434.     }
  435.  
  436.  
  437.     /* Now get information about the modeID */
  438.     if (GetDisplayInfoData(NULL, (UBYTE *) &displayinfo,
  439.         sizeof(struct DisplayInfo), DTAG_DISP, modeID))
  440.     {
  441.         /* True if PAL or DblPAL */
  442.         if (displayinfo.PropertyFlags & DIPF_IS_PAL)
  443.             IsPAL = TRUE;
  444.         else
  445.             IsPAL = FALSE;
  446.     }
  447.  
  448.  
  449. o  Incorrect assumptions about ColorMaps and ColorTables.
  450. The color system has undergone significant changes so new V39 graphic
  451. functions should be used to manage color whenever possible. 
  452. ColorMaps should always be allocated using GetColorMap(); freed using
  453. FreeColorMap(); colors changed using LoadRGB4/32(), SetRGB4/32(),
  454. or SetRGB4/32CM(); and colors queried using GetRGB4/32().
  455. Specifically, the value ColorMap->ColorTable and the structure it points
  456. to should never be poked or read directly. 
  457.  
  458. The color functions with names containing ``32'' are new V39 functions for
  459. getting, setting, and loading color registers.  These new functions treat
  460. color guns (R, G, B) each as 32-bit values for handling not only the
  461. 8-bit color available in AA but also any conceivable future needs.
  462. Use of these new 32-bit color functions is required to display the
  463. 16 million different color shades available under AA and V39.
  464. The old 4-bit color manipulation functions can only provide 4096
  465. different colors.  Use these new 32-bit color functions to ensure the
  466. future compatibility of your V39 applications.
  467.  
  468. When using 4 or 8-bit R/G/B values, scale your values to 32 bits.
  469. Scale 8 bit R/G/B values to 32 bits by duplicating the 8-bit value in
  470. all 4 bytes of the 32-bit value.  Scale 4-bit values to 32 bits by duplicating
  471. the 4 bit value in each nibble of the 32-bit value.
  472.  
  473.         4-bit red value $3  becomes $33333333
  474.         8-bit red value $1F becomes $1F1F1F1F
  475.         8-bit red value $03 becomes $03030303
  476.  
  477. The graphics.library VideoControl() function should be used to
  478. get, set, or clear the special features associated with ColorMaps.
  479.  
  480. o  Poking Copper lists or copinit.
  481. The structure and order of Copper lists will change for all modes,
  482. so any program that relies on poking the Copper lists will likely break.
  483. Certain programs (especially games) make assumptions about copinit and
  484. poke it directly.  These programs will break with the AA chips and V39
  485. unless the AA machine is running in a non-AA old-chip emulation mode.
  486. Note again that copinit has changed, and will continue to change.  Do Not Touch.
  487.  
  488. o  Dangerous bits in the display hardware.
  489. Many bits in the custom chip registers that were previously undefined
  490. now have a function.  Beware of poking the following bits.
  491.  
  492.     o  In BPLCON0: bits 0, 4, 5, 6, and 7
  493.  
  494.     o  In BPLCON2: bits 7, 8, 9
  495.  
  496.     o  In BPLCON3: bits 0,1,6,7, and bits 9 through 15
  497.  
  498. o  Illegal use of the processor to write to bitplane and sprite data registers.
  499. Bitplane and sprite data registers should NOT be written to by the processor.
  500. The correct way for data to be fed to the chips is by setting up DMA that
  501. points to the data in Chip memory.
  502.  
  503. o  Illegal re-use of sprites on the same line.
  504. Attempting to re-use sprites on the same horizontal line by redefining the
  505. sprite data is illegal and unsupported.  Sprites may only be re-used
  506. vertically, and then only with at least a one line gap between re-uses.
  507. See the Amiga Hardware Reference Manual for an example of sprite re-use.
  508.  
  509. o  Incorrect allocation of sprite image data.
  510. Because of the increased fetch bandwidth of the new chips, sprite image
  511. data must be properly aligned in Chip memory.  Under 2.0, the best way to
  512. allocate this memory is to call the Exec library AllocMem() function.
  513. Use the new AllocSpriteData() call for allocation of new mode sprites
  514. under V39 and higher.
  515.  
  516. o  Forgotten FreeSprite() call.
  517. Sprites may now have a number of different modes.  However, under Intuition,
  518. these modes are global to all sprites.  If a program gets a sprite in a
  519. particular mode, but then does not free it, Intuition (and all Intuition-based
  520. programs including Workbench) are forced to use sprites in the mode of the
  521. forgotten sprite.  In general, it is good practice to not use sprites other
  522. than the pointer when coding software that is meant to be Intuition-compatible.
  523.  
  524. o  Illegal use of Intuition pointer data.
  525. Intuition's pointer handling has become much more sophisticated.
  526. People playing tricky games with the pointer data may get into trouble
  527. if they make assumptions about the data format of the Intuition pointer
  528. which can change depending on the display mode.  
  529.  
  530. o The old SetPointer() and ClearPointer() functions still work,
  531. giving compatible Intuition pointers.  Likewise, the pointer imagery in
  532. devs:system-configuration will be used until a pointer.prefs file is
  533. received.  However, due to growing complexity in the pointer subsystem,
  534. calling SetPointer() or ClearPointer() from within an input handler or
  535. inside Begin/EndRefresh() runs a risk of deadlocking.  There are currently
  536. some patches in place to help prevent a deadlock, however we warn
  537. people to stick to simple rendering functions only when inside LockLayer(),
  538. LockLayerInfo(), BeginRefresh(), BeginUpdate(), etc. and not to call
  539. Intuition or other high-level system functions inside of LockIBase().
  540. As well, great care should be taken inside an input handler (it's generally
  541. best for the handler to signal a high-priority task which actually does the
  542. work).  Don't be the application that dies under the next release when an
  543. inappropriate function that happened to work now deadlocks because its
  544. handling has become more sophisticated.  See the Autodocs for these
  545. functions for more information on what other system calls are OK to use
  546. with these functions.
  547.             
  548. o Intuition and Graphics are involved in a scheme to maximize
  549. compatibility with older sprite-using applications.  The AA chipset
  550. supports variable sprite resolution and width, but the setting affects
  551. all sprites.  If an application requests a specific sprite width
  552. (through the old graphics.library/GetSprite() call or the new
  553. graphics.library calls (GetExtSpriteA() and ChangeExtSpriteA()), and
  554. Intuition's sprite is not compatible with that request, then
  555. graphics.library will blank Intuition's sprite and notify Intuition.
  556. Intuition will rebound by generating the most suitable pointer sprite
  557. which is compatible.
  558.  
  559. o Using an attached sprite for the Intuition pointer was quasi-supported
  560. under 2.0.  It no longer works.
  561.  
  562. o The pointer information returned by GetPrefs() is no longer kept
  563. up-to-date, since the pointer data can exceed the storage space
  564. available in struct Preferences.  (The ROM default pointer will be
  565. returned in all cases).  (Like V37, V39 ignores the pointer data in
  566. calls to SetPointer() after the first one, for reasons such as this).
  567.  
  568. o Pens for Screens
  569. The handling of defaults for the pen array is a bit involved because
  570. of compatibility issues.  The only change for old applications should
  571. be those who pass an SA_Pens array of {~0}.  They will get the new
  572. values for BARDETAILPEN, BARBLOCKPEN, and BARTRIMPEN.  This will only
  573. affect the color of their screen title bar, and the color of the menus of
  574. any window on that screen which requests new-look menus (WFLG_NEWLOOKMENUS).
  575. Applications that specify no SA_Pens array or ones who specify an SA_Pens
  576. array with at least one explicit pen provided get V37-compatible defaults.
  577. Our options were limited because the request for default palette and
  578. default pens were too loosely coupled (until SA_LikeWorkbench).
  579.  
  580. o Screen.BitMap is becoming obsolete.
  581. The original Screen structure has an embedded instance of a BitMap
  582. structure, which can not grow to support current needs.  When
  583. Intuition allocates a non-CUSTOMBITMAP screen's BitMap,
  584. it now uses AllocBitMap(), and just copies the old struct BitMap portion
  585. into the embedded &screen->BitMap.  Intuition internally now references the
  586. true BitMap (obtainable as screen->RastPort.BitMap) instead of &screen->BitMap.
  587. We recommend that applications do the same.  This is the direction we're
  588. headed anyways for RTG, and is needed for double-buffering.
  589. There are currently some patches in Intuition to handle people who are
  590. poking the Screen.BitMap depth or planes.  Such poking is strongly
  591. discouraged.  See the new V39 Intuition function ChangeScreenBuffer().
  592.  
  593. o  OpenScreen failure if too deep
  594. Since all modes and all depths are no longer available on every systems,
  595. OpenScreen will fail if you request a mode/depth combination that is not
  596. displayable.  This can be an issue both for applications which may
  597. have been counting on allocating extra planes this way, or counting
  598. on having extra planes which would not be displayed.
  599. There is a new SA_ErrorCode value, OSERR_TOODEEP.
  600.  
  601. o  Console compatibility
  602. Applications which draw graphics in the console portion of the window, but
  603. use console scroll commands may not work if they are drawing their text in
  604. other than pen 1 or pen 0 when only the bitplane for those colors is scrolled.
  605.  
  606. Applications that use pen sharing on their own screens should allocate and
  607. set pens 3-7 if they plan on using those colors in console.  The console
  608. device still uses pens 0-7 just as it always has.
  609.  
  610.  
  611. Promotion-Related Issues
  612.  
  613. Under V39 and AA, when Mode Promotion is turned on, display modes which
  614. use the default monitor (e.g. display modes which are not explicitly PAL
  615. or NTSC) are promoted to scan-doubled or de-interlaced modes such as
  616. DblPAL or DblNTSC to provide a flicker-free display.
  617. Mode Promotion, on or off, is controlled system-wide by the IControl
  618. Preferences editor and the availability of the DblNTSC or DblPAL
  619. monitor.
  620.  
  621. Mode promotion can change the behavior of the system in a manner which
  622. may be incompatible with certain applications.
  623.  
  624. o The overscan limits of DblNTSC (DblPAL) are a little less than the
  625. overscan limits of NTSC (PAL).  (For 3.01, the DblNTSC (DblPAL) limits
  626. have been extended and are now comparable to, but still less than, NTSC (PAL)).
  627.  
  628. o It may be harder to center a DblNTSC or DblPAL screen on certain
  629. multiscan monitors than it was to center a hardware de-interlaced NTSC or PAL
  630. screen.  (3.01 provides additional centering flexibility which
  631. helps solve this problem).
  632.  
  633. o An interlaced screen is promoted to a non-interlaced screen, which
  634. has obvious implications on custom copper-lists and copper-list pokers.
  635.  
  636. o The higher resolutions/depths of the AA chipset require higher
  637. alignment restrictions on bitplanes.  Fortunately, most applications
  638. either let Intuition allocate their screen's BitMap or else they
  639. have a custom BitMap whose width is a multiple of 64 pixels (the
  640. highest alignment currently required by AA).  However, if the
  641. custom BitMap is an unusual width, it may not be sufficiently
  642. aligned for the hardware.  Such a screen can come up skewed when
  643. promoted.
  644.  
  645. o Coercion of displays in back to match a promoted or explicit DblNTSC
  646. or DblPAL front display may result in a lower resolution mode for
  647. unsuitably aligned back displays.
  648.  
  649. "1x" modes require 16-pixel (word boundary) alignment of each
  650. scan-line.  "2x" modes require 32-pixel (longword boundary) alignment,
  651. while "4x" modes require 64-pixel (double-longword boundary)
  652. alignment.  Here is a short reference:
  653.  
  654.     o 140 ns pixels (lores in 15 kHz modes, extra-lores in 31 kHz modes)
  655.       1-8 planes require 1X
  656.  
  657.     o 70 ns pixels (hires in 15 kHz modes, lores in 31 kHz modes)
  658.       1-4 planes require 1X
  659.       5-8 planes require 2X
  660.  
  661.     o 35 ns pixels (super-hires in 15 kHz modes, hires in 31 kHz modes)
  662.       1-2 planes require 1X
  663.       2-4 planes require 2X
  664.       5-8 planes require 4X
  665.  
  666. As the graphics.library AllocBitMap() function takes care of
  667. allocating suitably-aligned BitMaps for you, you do not need to worry
  668. about alignment when using modern system calls.
  669.  
  670. o The AA hardware does not allow dual-playfield non-interlaced screens
  671. to be scan-doubled, so they will appear half as tall as their
  672. non-promoted counterparts.
  673.  
  674. o Like earlier chipsets, the AA chipset still supports eight sprites.
  675. In much the same way as ECS and original chipsets lose sprites when
  676. overscan is increased, many of the new modes have insufficient spare
  677. cycles to fetch data for these sprites.  A promoted screen may have
  678. fewer sprites left than the corresponding 15 kHz mode, meaning that
  679. some sprites other than the pointer sprite may vanish.
  680.  
  681. NOTE - If the system is aware that additional sprites are needed,
  682. it will attempt to drop a display's bandwidth (if possible) to allow
  683. additional sprites.  To cause this to happen, either GetSprite() your
  684. sprites before opening your display, or RemakeDisplay() after doing
  685. your GetSprite() calls.
  686.  
  687. o  There is currently no 31 kHz mode having 1280 pixels per line.
  688. That would require 17.5 ns pixel speeds, which is twice what the
  689. AA chipset is capable of.  Therefore, SuperHires screens are promoted
  690. to 640 pixel-per-line screens, which generally can scroll.
  691. This is required for systems which have a VGA-only monitor, but otherwise
  692. might not be the desired way to display this mode.  To prevent promotion of
  693. SuperHires to Hires, an application could ask explicitly for PAL
  694. or NTSC SuperHires.  However, keep in mind that future chipsets
  695. may be capable of de-interlacing 1280-wide displays, and this would
  696. be defeated if NTSC or PAL is explicitly requested.  Also remember
  697. that a user with a VGA-only monitor can not display these modes.  The V39
  698. BestModeIDA() function may be used to determine the best available mode.
  699.  
  700. o  Applications that specifically request the NTSC or PAL monitor when
  701. opening a display will receive non-promoted PAL or NTSC, suitable for
  702. genlocking, etc.  For interlace modes, this will not be a flicker-free display.
  703. Therefore, productivity and design applications that wish to offer
  704. an explicit PAL/NTSC choice should use the display database or 2.1
  705. ASL screen mode requester to allow the user to choose a flicker-free
  706. display mode that is available on their system.
  707.  
  708.  
  709. Other Compatibility Issues
  710.  
  711. o  Library Vector Offsets and SetFunction().
  712. In general, some new LVOs supersede old ones.  While the old ones still work,
  713. software that calls SetFunction() based on the old LVOs may no longer catch
  714. what they were hoping to.  An example from V37 was people who called
  715. SetFunction() on AutoRequest().  Most system requests go through EasyRequest()
  716. now.  A V39 example would be SetWindowPointer() replacing SetPointer().
  717.  
  718. o  Test for Memory by Poking Breaks
  719. Apparently, some games test for RAM at $200000 by writing a pattern
  720. there and immediately reading it back.  On the A1200 bus, such games
  721. will be fooled.  Never test for RAM by poking/peeking.  Always use
  722. Exec's memory allocation functions, or the Exec TypeOfMem() function
  723. which can tell the caller whether (and what type of) memory exists at
  724. any particular address.
  725.  
  726. o  Preferences file format changes
  727. The format of some Preferences files have changed of necessity to
  728. support new system capabilities, and these files may continue to change.
  729. The documentation which has been provided only shows some chunks which
  730. may be encountered in a system Preferences file.  There is no guarantee
  731. that new chunks will not be added, or that the current chunks will
  732. continue to be used.   Do not read or write system Preferences files.
  733. Instead use other provided system mechanisms for reading and setting
  734. such items (for example, use device-specific commands or structures for
  735. controlling device preferences, functions such as QueryOverscan() and
  736. LockPubScreen() for determining display characteristics, etc.)
  737.  
  738. o  Changes to support for width-scaling of fonts
  739. Under V37, different widths of one YSize of a scalable font could
  740. be opened with a tagged OpenDiskFont() by first running a patch called
  741. setpatchwtam.  Under V38, this patch program does nothing, and an
  742. incorrect already-opened width may be returned.  Under V39, the correct
  743. requested width should again be returned, and these loaded width-scaled
  744. fonts are both hidden from AvailFonts() and should not be accidentally
  745. provided if application just does OpenFont() for the same YSize.
  746.  
  747. o  Self-modifying, copied, and directly loaded code
  748. Self-modifying code without proper cache control has been breaking
  749. since the 68020 was introduced.  The larger caches of the 68030 and 68040
  750. processors make it even more necessary to use the exec cache control
  751. functions such as CacheClearU() which have been available since V37.
  752. The cache control functions make it possible to flush the processor
  753. caches after modifying code in place, copying code to a different memory
  754. address, or placing code into memory via any mechanism that bypasses LoadSeg.
  755. Cache-control functions are also provided for DMA controllers which
  756. DMA data into memory.
  757.  
  758. o  IFF code
  759. Older IFF sample/example code contains many hardcoded limits and
  760. accesses some structures which may no longer be accessed directly.
  761. The older code (and even the code listed in the Amiga ROM Kernel Reference
  762. Manual: Devices, 3rd Edition) also would not load more than 32 color registers.
  763. The new IFF code, NewIFF39.lzh, attempts to use the latest system functions
  764. wherever possible in a conditional backward-compatible manner.
  765. The new code provides support for the full AA color palette, arbitrary
  766. display modes, the clipboard, overscan and autoscroll screens, and
  767. loading/saving of 24-bit ILBMs.  Please see the ILBM Compatibility
  768. notes for additional information on ILBM compatibility and support
  769. of AA features.
  770.  
  771.  
  772. o Tablet driver writers should test that their tablets now work with
  773. console drag selection (known not to work in the 2.04 OS).
  774.  
  775.  
  776. o Pre/Post DMA Cache functions and 68040
  777. For those of you with DMA devices that need to use the CachePreDMA()
  778. and CachePostDMA() calls:  Be careful as incorrect use of these
  779. calls may look like they work fine in 68000/68020/68030 systems but
  780. may cause strange system behavior and even major system slowdown
  781. on 68040 systems.
  782.  
  783. The correct way to use these calls is:
  784.  
  785.     original_length=length;
  786.     CachePreDMA(address,&length,0);
  787.  
  788.     /* Optional, multiple ones here for breaking up
  789.      * DMA operations within the single larger DMA block
  790.      * defined in the first call to CachePreDMA()
  791.      */
  792.     CachePreDMA(....,....,DMA_Continue);
  793.  
  794.     /*
  795.      * Very important to call CachePostDMA() with the
  796.      * exact same values as CachePreDMA()
  797.      */
  798.     CachePostDMA(address,&original_length,0)
  799.  
  800. Also, you must make sure they match up.  If they do not, the system will not
  801. be able to figure out that the DMA that was starting has finished.
  802. Internally, the OS needs to track these things for the 68040 and higher
  803. processors and may need to track them even more in the future.
  804.  
  805.  
  806. o An upcoming release of 3.0 (3.01?) will support the dos.library SetVBuf()
  807. function.  From V36 to V39 this call did nothing.  It will now properly change
  808. buffering modes, sizes, etc.  For programs using Dos buffered IO calls
  809. (FGetC, FPutC, FRead, etc) this can make a major improvement in IO
  810. performance if the buffer size is increased (and if the buffering mode
  811. is changed when writing to BUF_FULL).
  812.  
  813.  
  814. For additional information on OS changes, take particular note of all
  815. BUGS and NOTES entries in the sytem autodocs.
  816.  
  817.  
  818.  
  819.  
  820. Taking Advantage of New Features
  821.  
  822. By simply using system features and functions which were introduced
  823. in Release 2, you can write adaptable software that can automatically grow
  824. and support many new system software and hardware capabilities.
  825.  
  826.  
  827. Add a bit of conditional code to treat color guns (R, G, and B) as
  828. at least 8-bits each, and to conditionally use the new 32-bit V39 color
  829. setting and getting functions, and your application can provide full
  830. AA palette support.
  831.  
  832.  
  833.  
  834. Here are some strategies for adapting to new system capabilities.
  835.  
  836. o  Use the asl.library requesters if available.
  837. They are localized, they cut down on the amount of code you have to
  838. maintain, and they grow with the system.  2.0 Workbench licensees may
  839. get a free amendment to distribute the 2.1 asl.library which contains
  840. the screen mode requester.
  841.  
  842. o  Adapt to previously impossible deeper modes.
  843. Properly written software can use the calling syntax of the current graphics
  844. and Intuition library functions to open the screen modes with larger numbers
  845. of bitplanes.  These modes are simply deeper bitplane versions of existing modes:
  846. Lores 6,7, and 8 bits; Hires 5,6,7, and 8 bits; SuperHires 3,4,5,6,7,
  847. and 8 bits; and VGA 3,4,5,6,7, and 8 bits.  
  848.  
  849. Note that the display database must be checked to see if the user's
  850. machine supports the desired mode and number of bitplanes.
  851.  
  852. Intuition's screen functions can be used to open these previously
  853. impossible screens, but programs cannot rely on Intuition to throw out
  854. all "bad" possibilities.  For example, V36 Intuition will open an
  855. 8-bitplane Lores screen, but this is a waste of memory if the new chip
  856. set is not present since the 3 extra bitplanes will simply go unused.
  857. Programs will therefore need to explicitly check the display database
  858. to find out what the chips support.  In V39, Intuition will check the
  859. chips for you and fail to open a screen which is "too deep".  There is
  860. a new SA_ErrorCode value, OSERR_TOODEEP.
  861.  
  862.  
  863. Note on Mode IDs.  The currently defined display database mode IDs have
  864. all been moved from <graphics/displayinfo.h> to the new include file
  865. <graphics/modeid.h>.  Do not attempt to create your own display mode
  866. IDs by OR'ing together monitors and modes unless the include file
  867. explicitly allows it.  Do not try to draw conclusions about display
  868. characteristics by interpreting bits in the display mode ID.  Instead,
  869. pass the mode ID to the display database functions to discover the
  870. display characteristics (see the example below and other examples in
  871. Amiga Mail, Devcon Notes, Amiga RKRM: Libraries manual, and the new
  872. screen mode requester example).
  873.  
  874. The complete example listed below will check the display database
  875. entry for a LORES screen and open a screen with the maximum allowable
  876. number of bitplanes (assuming there is enough Chip memory).  On an Amiga
  877. with any chip set up to and including ECS, this code will open a
  878. 5-bitplane screen.  On a machine with the AA chip set, the screen will
  879. be 8 bits deep.  The code will then draw one vertical line for each
  880. available color using Intuition's preferred palette (which can be 
  881. set by the user with Preferences).  The example requires V36 or a
  882. later version of the OS.
  883.  
  884. /*  maxdepthlores.c  */
  885.  
  886. #include <exec/types.h>
  887. #include <intuition/intuition.h>
  888. #include <graphics/displayinfo.h>
  889. #include <dos/dos.h>
  890.  
  891. #include <clib/exec_protos.h>
  892. #include <clib/intuition_protos.h>
  893. #include <clib/graphics_protos.h>
  894. #include <clib/dos_protos.h>
  895.  
  896. #include <stdio.h>
  897. #include <stdlib.h>
  898.  
  899. struct Library *IntuitionBase;
  900. struct Library *GfxBase;
  901.  
  902. void Quit(char *whytext,LONG failcode)
  903. {
  904.     if(*whytext) printf("%s\n",whytext);
  905.  
  906.     if (IntuitionBase)    CloseLibrary(IntuitionBase);
  907.     if (GfxBase)    CloseLibrary(GfxBase);
  908.  
  909.     exit(failcode);
  910. }
  911.  
  912. void main(void)
  913. {
  914.     ULONG modeID = LORES_KEY;
  915.     DisplayInfoHandle displayhandle;
  916.     struct DimensionInfo dimensioninfo;
  917.  
  918.     UWORD maxdepth, maxcolors;
  919.     ULONG soerror = NULL,colornum;
  920.     struct Screen *screen;
  921.  
  922.     if ((GfxBase = OpenLibrary("graphics.library",36))==NULL)
  923.         Quit("graphics.library is too old <V36",RETURN_FAIL);
  924.  
  925.     if ((IntuitionBase = OpenLibrary("intuition.library",36))==NULL)
  926.         Quit("intuition.library is too old <V36",RETURN_FAIL);
  927.  
  928.     if ((displayhandle=FindDisplayInfo(modeID))==NULL)
  929.         Quit("modeID not found in display database",RETURN_FAIL);
  930.  
  931.     if (GetDisplayInfoData(displayhandle,(UBYTE *) &dimensioninfo,
  932.     sizeof(struct DimensionInfo),DTAG_DIMS,NULL)==0)
  933.         Quit("mode dimension info not available",RETURN_FAIL);
  934.         
  935.     maxdepth=dimensioninfo.MaxDepth;
  936.     printf("dimensioninfo.MaxDepth=%d\n",(int) maxdepth);
  937.  
  938.     if (screen=OpenScreenTags(NULL, SA_DisplayID    ,modeID,
  939.                                     SA_Depth        ,(UBYTE) maxdepth,
  940.                                     SA_Title        ,"MaxDepth LORES",
  941.                                     SA_ErrorCode    ,&soerror,
  942.                                     SA_FullPalette  ,TRUE,
  943.                                     TAG_END))
  944.         {
  945.             /* Zowee! we actually got the screen open!
  946.              * now let's try drawing into it.
  947.              */
  948.             maxcolors=1<<maxdepth;
  949.             
  950.             printf("maxcolors=%d\n",(int) maxcolors);
  951.             
  952.             for(colornum=0;colornum<maxcolors;++colornum)
  953.             {
  954.                 SetAPen(&(screen->RastPort),colornum);
  955.                 Move(&(screen->RastPort),colornum,screen->BarHeight + 2);
  956.                 Draw(&(screen->RastPort),colornum,screen->Height - 1);
  957.             }
  958.             Delay(TICKS_PER_SECOND * 6);
  959.  
  960.             CloseScreen(screen);
  961.         }            
  962.     else
  963.         {   /* Hmmm.  Couldn't open the screen.  maybe not
  964.              * enough CHIP RAM? Maybe not enough chips! ;-)
  965.              */
  966.             switch(soerror)
  967.             {
  968.                 case OSERR_NOCHIPS:
  969.                     Quit("Bummer! You need new chips dude!",RETURN_FAIL);
  970.                     break;
  971.                 
  972.                 case OSERR_UNKNOWNMODE:
  973.                     Quit("Bummer! Unknown screen mode.",RETURN_FAIL);
  974.                     break;
  975.                 
  976.                 case OSERR_NOCHIPMEM:
  977.                     Quit("Not enough CHIP memory.",RETURN_FAIL);
  978.                     break;
  979.                 
  980.                 case OSERR_NOMEM:
  981.                     Quit("Not enough FAST memory.",RETURN_FAIL);
  982.                     break;
  983.                 
  984.                 default:
  985.                     printf("soerror=%d\n",soerror);
  986.                     Quit("Screen opening error.",RETURN_FAIL);
  987.                     break;
  988.             }
  989.             Quit("Couldn't open screen.",RETURN_FAIL);
  990.         }
  991.  
  992. Quit("",RETURN_OK);    /* clean up and exit */
  993. }
  994.  
  995.  
  996.  
  997. o  Open on Workbench.
  998. One of the easiest ways to help a given program peacefully coexist with
  999. new hardware is to allow it to open on the Workbench screen (or on any
  1000. public screen).  Software written this way should be robust enough that
  1001. it can find out from the system any information it might need about the
  1002. display environment, and, if it understands the kind of screen that it's
  1003. on, use the appropriate graphics.library calls to manipulate its windows.
  1004.  
  1005. Here's some example code that determines the depth of the default public
  1006. screen and opens a window on it.  If it were part of a real application,
  1007. this code would tell how many colors the screen has.
  1008.  
  1009. Add some conditional V39 palette sharing code and you can even have
  1010. your own color registers to use, if available, or closest matching
  1011. register to share.
  1012.  
  1013.  
  1014. /* depthawarevisitor.c */
  1015.  
  1016. #include <exec/types.h>
  1017. #include <intuition/intuition.h>
  1018. #include <graphics/displayinfo.h>
  1019. #include <dos/dos.h>
  1020.  
  1021. #include <clib/exec_protos.h>
  1022. #include <clib/intuition_protos.h>
  1023. #include <clib/graphics_protos.h>
  1024. #include <clib/dos_protos.h>
  1025.  
  1026. #include <stdio.h>
  1027. #include <stdlib.h>
  1028.  
  1029.  
  1030. struct Library *IntuitionBase;
  1031. struct Library *GfxBase;
  1032. struct Screen  *screen = NULL;
  1033.  
  1034.  
  1035. void Quit(char *whytext, LONG failcode)
  1036. {
  1037.     if(*whytext) printf("%s\n",whytext);
  1038.  
  1039.     if (screen)        UnlockPubScreen(NULL, screen);
  1040.     if (IntuitionBase)    CloseLibrary(IntuitionBase);
  1041.     if (GfxBase)    CloseLibrary(GfxBase);
  1042.  
  1043.     exit(failcode);
  1044. }
  1045.  
  1046.  
  1047. void main(void)
  1048. {
  1049.     struct Screen *screen;
  1050.     struct DrawInfo *drawinfo;
  1051.     struct Window *window;
  1052.     UWORD depth;
  1053.  
  1054.     if ((GfxBase = OpenLibrary("graphics.library",36))==NULL)
  1055.         Quit("graphics.library is too old <V36",RETURN_FAIL);
  1056.  
  1057.     if ((IntuitionBase = OpenLibrary("intuition.library",36))==NULL)
  1058.         Quit("intuition.library is too old <V36",RETURN_FAIL);
  1059.  
  1060.     if (!(screen = LockPubScreen(NULL)))
  1061.         Quit("Can't lock default public screen",RETURN_FAIL);
  1062.  
  1063.     /* Here's where we'll ask Intuition about the screen. */
  1064.     if((drawinfo=GetScreenDrawInfo(screen)) == NULL)
  1065.     Quit("Can't get DrawInfo",RETURN_FAIL);
  1066.  
  1067.     depth=drawinfo->dri_Depth;
  1068.  
  1069.     /* Because Intuition allocates the DrawInfo structure,
  1070.      * we have to tell it when we're done, to get the memory back.
  1071.      */
  1072.     FreeScreenDrawInfo(screen, drawinfo);
  1073.  
  1074.     /* This next line takes advantage of the stack-based amiga.lib
  1075.      * version of OpenWindowTags.
  1076.      */
  1077.     if (window = OpenWindowTags(NULL, WA_PubScreen ,screen,
  1078.                                       WA_Left      ,0,
  1079.                                       WA_Width     ,screen->Width,
  1080.                                       WA_Top       ,screen->BarHeight,
  1081.                                       WA_Height    ,screen->Height - screen->BarHeight,
  1082.                                       WA_Flags     ,WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|
  1083.                                                     ACTIVATE|SIMPLE_REFRESH|NOCAREREFRESH,
  1084.                                       WA_Title     ,"Big Visitor",
  1085.                                       TAG_END))
  1086.     {
  1087.  
  1088.         printf("depth=%d\n",depth);
  1089.         
  1090.         /* All our window event handling might go here */
  1091.  
  1092.         Delay(TICKS_PER_SECOND * 10);
  1093.  
  1094.         /* Of course, some other program might come along
  1095.          * and change the attributes of the screen that we read from
  1096.          * DrawInfo, but that's a mean thing to do to a public screen,
  1097.          * so let's hope it doesn't happen.
  1098.          */
  1099.  
  1100.         CloseWindow(window);
  1101.     }
  1102.  
  1103. Quit("",RETURN_OK);    /* clean up (close/unlock) and exit */
  1104. }
  1105.  
  1106.  
  1107. o  If necessary, use tag-extended older structures with 1.3 functions.
  1108. If you are not yet able to drop support for 1.3 systems, use tag-extended
  1109. structures such as ExtNewScreen and ExtNewWindow to provide V37 and V39/AA
  1110. enhanced capabilities with 1.3-compatible code.  See the RKM Libraries volume
  1111. Intuition chapters for examples which use these tag-extended structures.
  1112. An example of such coding is the NewIFF39 code.
  1113.  
  1114.  
  1115.  
  1116. ****************************************************************************
  1117. MARK RICCI - Please get this table and all of the footnotes that follow
  1118. it from Dan Baker's ProPage V39 Notes Compatibility doc.
  1119. ****************************************************************************
  1120.              
  1121. Table 1:  New AA Display Modes (In Addition to Modes Supported by ECS)
  1122.